# Contributor: John Regan <john@jrjrtech.com>
# Maintainer: Laurent Bercot <ska-devel@skarnet.org>
pkgname=s6
pkgver=2.13.1.0
pkgrel=0
pkgdesc="skarnet.org's small & secure supervision software suite."
url=https://skarnet.org/software/s6/
arch="all"
license="ISC"
_skalibs_version=2.14.3
_execline_version=2.9.6
makedepends="skalibs-dev>=$_skalibs_version execline-dev>=$_execline_version"
depends="s6-ipcserver execline"
options="!check"
subpackages="$pkgname-ipcserver $pkgname-static $pkgname-libs $pkgname-dev $pkgname-doc $pkgname-openrc"
source="https://skarnet.org/software/s6/s6-$pkgver.tar.gz s6-svscanboot s6.initd s6.pc.in"
install="s6.pre-install s6.pre-upgrade"
triggers="s6.trigger=/run/service"

_ipcserver_binaries="usr/bin/s6-ipcserver usr/bin/s6-ipcserver-socketbinder usr/bin/s6-ipcserverd usr/bin/s6-applyuidgid"

build() {
	./configure \
		--prefix=/usr \
		--enable-shared \
		--disable-allstatic \
		--libexecdir="/usr/lib/$pkgname"
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -D "$srcdir/s6-svscanboot" "$pkgdir/usr/lib/s6/s6-svscanboot"
	install -D "$srcdir/s6.initd" "$pkgdir/etc/init.d/s6"
	sed -e "s/@@VERSION@@/$pkgver/g; s/@@SKALIBS_VERSION@@/${_skalibs_version}/g; s/@@EXECLINE_VERSION@@/${_execline_version}/g;" "$srcdir/$pkgname.pc.in" > "$srcdir/$pkgname.pc"
	install -D -m 0644 "$srcdir/$pkgname.pc" "$pkgdir/usr/lib/pkgconfig/$pkgname.pc"
	mkdir -p "$pkgdir/usr/share/doc"
	cp -a "$builddir/doc" "$pkgdir/usr/share/doc/$pkgname"
}

ipcserver() {
	depends=""
	amove $_ipcserver_binaries
}

sha512sums="
89912f627d239e9d0b830c97e3b35b0358ac3ea1b3b958de091318e19ee9ca0bac0a008f114682bc0ed8388e15592ffd683c4bbf1128fe7109cad16f18a1065b  s6-2.13.1.0.tar.gz
206cdc275b81e60d8c8b7553ed1ce52ef0a868c853ccbb278e99459a8597fe650d1869973ca0a4526695664f0e853abfdae1a606276ab84db28d33d886f60751  s6-svscanboot
ee1ebabce2cb0d979417f4ed3e6d301e9aba9ab65738d8d64b7b4b83c190e0e60d2d00fa4d4de65bb16da5e0ff98ffbe870cc73134bd53ad72a7009f137fd262  s6.initd
0af788e78b5840a0ed612de6d2c15bc868d4f2444063f283af1ac42aec7029af24c660abf65c7d9fa369aa1ca96bb8503ffffe37db531fdd75b80db570888a38  s6.pc.in
"
